package org.example.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import feign.Param;
import org.example.model.TrafficDO;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author 谢超
 * @since 2023-07-16
 */
public interface TrafficMapper extends BaseMapper<TrafficDO> {

    /**
     * 查找可⽤的短链流量包列表(未过期),包括免费流量包
     * @param accountNo
     * @return
     */
//    List<TrafficDO> selectAvailableTraffics(Long accountNo);

    /**
     * 给某个流量包增加使⽤次数
     * @param trafficId
     * @param accountNo
     * @param usedTimes
     * @return
     */
    int addDayUsedTimes(@Param("accountNo") Long accountNo, @Param("trafficId") Long trafficId, @Param("usedTimes") Integer usedTimes);

    /**
     * 恢复流量包使⽤当天次数，回滚流量包
     * @param accountNo
     * @param trafficId
     * @param usedTimes
     */
    int releaseUsedTimes(@Param("accountNo") Long accountNo, @Param("trafficId") Long trafficId, @Param("usedTimes") Integer usedTimes, @Param("userDateStr") String userDateStr);

}

